console.log(location.href)
var url = location.href
var wangzhi = getUrlParams(url)
console.log(wangzhi)  //获取到了携带的productid值，可以根据此值展示不同的页面
let { productid } = wangzhi
console.log({productid})
var main = document.querySelector('main')
var xhr = new XMLHttpRequest()
xhr.open('get', `http://chst.vip:1234/api/getmoneyctrlproduct?productid=${productid}`)
xhr.send()
xhr.onreadystatechange = function () {
    if (xhr.status === 200 && xhr.readyState === 4) {
        console.log(xhr.responseText)
        var x = JSON.parse(xhr.responseText).result[0]

        console.log(x)

        var html = ""
        html += `<h4>${x.productName}</h4>
            <span>${x.productFrom}|${x.productTime}</span>
            <i>${x.productTips}</i>
            <div>
               
               ${x.productImg2}
               <p>${x.productInfo2}</p>
            </div>
            ${x.productImg2}
            ${x.productCity}
            <h1>前往购买</h1>
            <img src="../assets/images/mmbweixin2.png">
           ${x.productComment}
            `
        main.innerHTML = html
        //前往购买和发表评论全是刷新网页
        var h1 = document.querySelector('main>h1')
        var input1= document.querySelector('.tjdp')
        console.log(input1)
        h1.onclick = function () {
            location.reload()
        }
        input1.onclick = function () {
            console.log(1)
            location.reload()
        }
    }
}
//书写返回index.html功能
var fanhui=document.querySelector('header>a')
fanhui.onclick=function(){
    location.href="../index.html"
}

